home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / up1510b.tgz / up1510b / src / tools / boot.s next >
Text File  |  1990-07-15  |  1KB  |  91 lines

  1. #include "type.s"
  2.  
  3. ! offsets in this boot block:
  4. sizes    = 480
  5. magic    = 502
  6. nsect    = 504
  7. fsckd    = 506
  8. zero    = 508
  9. fsckt    = 510
  10.  
  11. BIOS    = 13
  12. RWABS    = 4
  13. GETBPB    = 7
  14.  
  15. _bootdev    = 0x0446
  16. ldaddr        = 0x040000
  17.  
  18. boot:
  19.     move.w    _bootdev.l,-(sp)
  20.     move.w    #GETBPB,-(sp)
  21.     trap    #BIOS
  22.     add.w    #4,sp
  23.     tst.l    d0
  24.     beq    fail
  25.     clr.w    d6        ! start with block 0
  26.     lea    start+sizes(pc),a4 ! address of sector table
  27.     add.w    #1,(a4)        ! count boot block
  28.     move.l    #ldaddr,a3    ! load address in memory
  29. read:
  30.     clr.l    d4        ! load sectors from disc
  31.     move.w    (a4)+,d4
  32.     beq    4f        ! count of 0 means loading finished
  33.     bsr    rwabs
  34.     bne    fail
  35.     add.w    d4,d6
  36.     asl.l    #8,d4
  37.     asl.l    #1,d4
  38.     add.l    d4,a3
  39.  
  40.     clr.l    d0        ! create bss area of part
  41.     move.w    (a4)+,d0
  42.     asl.l    #8,d0
  43.     beq    read
  44. 3:
  45.     clr.w    (a3)+
  46.     sub.l    #1,d0
  47.     bne    3b
  48.     bra    read
  49. 4:
  50.     lea    copy(pc),a0
  51.     lea    start(pc),a1
  52.     sub.l    a1,a0
  53.     add.l    #ldaddr,a0
  54.     jmp    (a0)        ! jump to copy routine at ldaddr
  55.  
  56. copy:
  57.     move.w    #0x2700,sr
  58.     move.l    #8,a0
  59.     move.l    #ldaddr+0x208,a1! start address of minix
  60.     move.l    #0x400,d0
  61. 2:    move.l    (a1)+,(a0)+
  62.     cmp.l    a0,d0
  63.     bne    2b
  64.     add.l    #0x200,a0    ! skip tos variables
  65.     add.l    #0x200,a1
  66.     clr.l    d0
  67.     move.w    start+nsect(pc),d0
  68.     asl.l    #8,d0        ! multiply
  69.     asl.l    #1,d0        ! with 512
  70. 3:    move.l    (a1)+,(a0)+
  71.     cmp.l    a0,d0
  72.     bne    3b
  73.     move.l    ldaddr+0x204,a0
  74.     jmp    (a0)        ! minix boot address
  75.  
  76. fail:
  77.     clr.l    d0        ! cannot load MINIX; try next device
  78.     rts
  79.  
  80. rwabs:
  81.     move.w    _bootdev.l,-(sp)
  82.     move.w    d6,-(sp)
  83.     move.w    d4,-(sp)
  84.     move.l    a3,-(sp)
  85.     clr.w    -(sp)
  86.     move.w    #RWABS,-(sp)
  87.     trap    #BIOS
  88.     add.w    #14,a7
  89.     tst.w    d0
  90.     rts
  91.